<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
		<meta http-equiv="Cache-Control" content="no-siteapp" />
		<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
		<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
		<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
		<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
		<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
		<link rel="stylesheet" type="text/css" href="lib/share/css/share.css" />
		<link href="lib/share_phone/css/style.css" type="text/css" rel="stylesheet" />
		<link href="lib/share_phone/css/list-to-detail.css" type="text/css" rel="stylesheet" />
		<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
		<title>资讯列表</title>
		<style type="text/css">
			/* * {
				margin: 0;
				padding: 0;
				list-style-type: none;
			}
 */
			a,
			img {
				border: 0;
			}

			body {
				font: 12px/180% Arial, Helvetica, sans-serif, "新宋体";
			}

			/* iphonebox */
			.iphonebox {
				background: url(lib/share_phone/images/iphone5.png) no-repeat;
				background-size: 100% 100%;
				;
				width: 320px;
				height: 100%;
				overflow: hidden;
				padding: 110px 0 0 27px;
				margin: 0 auto;
			}

			.webbox {
				position: relative;
				width: 292px;
				height: 500px;
				overflow: hidden;
			}

			#header {
				position: absolute;
				z-index: 2;
				top: 0;
				left: 0;
				width: 100%;
				height: 45px;
				line-height: 45px;
				padding: 0;
				color: #eee;
				font-size: 20px;
				text-align: center;
				background-color: #d51875;
				background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #fe96c9), color-stop(0.05, #d51875), color-stop(1, #7b0a2e));
				background-image: -moz-linear-gradient(top, #fe96c9, #d51875 5%, #7b0a2e);
				background-image: -o-linear-gradient(top, #fe96c9, #d51875 5%, #7b0a2e);
			}

			#header a,
			#footer a {
				color: #f3f3f3;
				text-decoration: none;
				font-weight: bold;
				text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5);
			}

			#footer {
				position: absolute;
				z-index: 2;
				bottom: 0;
				left: 0;
				width: 100%;
				height: 48px;
				line-height: 48px;
				padding: 0;
				border-top: 1px solid #444;
				color: #eee;
				font-size: 20px;
				text-align: center;
				background-color: #222;
				background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #999), color-stop(0.02, #666), color-stop(1, #222));
				background-image: -moz-linear-gradient(top, #999, #666 2%, #222);
				background-image: -o-linear-gradient(top, #999, #666 2%, #222);
			}

			#wrapper {
				position: absolute;
				z-index: 1;
				top: 0px;
				bottom: 96px;
				left: 0;
				width: 100%;
				background: #efeff4;
				/* overflow: hidden; */
				overflow-y: scroll;
				white-space: normal;
				word-break: break-all;
			}

			#wrapper::-webkit-scrollbar {
				display: none;
			}

			/* #wrapper > div {
			    width: 100%;
			    height: 300px;
			    line-height: 30px;
			    overflow-y: scroll;
			} */

			/* scroller */
			#scroller li {
				padding: 5px 0;
				border-bottom: 1px solid #ccc;
				border-top: 1px solid #fff;
				background-color: #fafafa;
				font-size: 14px;
				height: 85px;
				vertical-align: bottom;
			}

			#scroller li img {
				float: left;
				width: 111px;
				height: 83px;
			}

			#scroller li span {
				float: left;
				margin: 30px 0 0 6px;
			}

			/* swipe */
			.swipe {
				width: 326px;
				height: 235px;
				overflow: hidden;
				position: relative;
			}

			.swipe ul {
				-webkit-transition: left 800ms ease-in 0;
				-moz-transition: left 800ms ease-in 0;
				-o-transition: left 800ms ease-in 0;
				-ms-transition: left 800ms ease-in 0;
				transition: left 800ms ease-in 0;
			}

			.swipe #pagenavi {
				position: absolute;
				left: 0;
				bottom: 10px;
				text-align: center;
				width: 100%;
			}

			.swipe #pagenavi a {
				width: 14px;
				height: 14px;
				line-height: 99em;
				background: #b5b5b5;
				-webkit-border-radius: 50%;
				-moz-border-radius: 50%;
				border-radius: 50%;
				margin: 0 4px;
				overflow: hidden;
				cursor: pointer;
				display: inline-block;
				*display: inline;
				*zoom: 1;
			}

			.swipe #pagenavi a.active {
				background: #C80002;
			}

			#kr-article-article .container {
				width: 100%;
				padding: 0;
				margin: 0;
			}
		</style>
	</head>
	<body>
		<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span>
			小知识/培训列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);"
			 title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
		<div class="page-container">
			<!-- <div class="text-c">
				<span class="select-box inline">
					<select name="" class="select">
						<option value="0">全部分类</option>
						<option value="1">小知识</option>
						<option value="2">培训</option>
					</select>
				</span> 日期范围：
				<input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'logmax\')||\'%y-%M-%d\'}' })" id="logmin" class="input-text Wdate"
				 style="width:120px;">
				-
				<input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'logmin\')}',maxDate:'%y-%M-%d' })" id="logmax" class="input-text Wdate"
				 style="width:120px;">
				<input type="text" name="" id="" placeholder=" 小知识/培训名称" style="width:250px" class="input-text">
				<button name="" id="" class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜小知识/培训</button>
			</div> -->
			<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i
						 class="Hui-iconfont">&#xe6e2;</i> 删除</a> <a class="btn btn-primary radius" data-title="添加小知识/培训" data-href="article-add.html"
					 onclick="system_category_add('添加','article-add.html')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i>
						添加小知识/培训</a>
					<!-- <a onclick="phone_click();" href="javascript:void(0)" class="share">手机预览</a> --></span> </div>
			<div class="mt-20">

				<table id="table_id" class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
					<thead></thead>
					<tbody id="tbody_id"></tbody>
				</table>
			</div>
		</div>
		<!--_footer 作为公共模版分离出去-->
		<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
		<!-- <script type="text/javascript" src="lib/share/js/share.js"></script> -->
		<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
		<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
		<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>
		<!--/_footer 作为公共模版分离出去-->

		<!--请在下方写此页面业务相关的脚本-->
		<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
		<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
		<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
		<script type="text/javascript" src="lib/share_phone/js/touchScroll.js"></script>
		<script type="text/javascript" src="lib/share_phone/js/touchslider.dev.js"></script>
<script type="text/javascript" src="js/jquery.base64.js"></script>

		<script type="text/javascript">
			var urlPort="http://39.100.91.49:8060";
			var url = urlPort+"/articles/getArticlesBy";
			$(".table-sort").dataTable({
				"bProcessing": true, //DataTables载入数据时，是否显示‘进度’提示
				"bAutoWidth": true, //是否自适应宽度  
				//stateSave: true,
				"lengthMenu":[10, 50, 100],
				"pageLength": 100,
				"aaSorting": [
					[6, "desc"]
				], //默认第几个排序
				"aoColumnDefs": [
					//{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
					{
						"orderable": false,
						"aTargets": [0, 8]
					} // 制定列不参与排序
				],
				"aoColumns": [{
					"mDataProp": this.settings,
					"sTitle": "<input type='checkbox' value=''/>",
					"sDefaultContent": "", //此列默认值为""，以防数据中没有此值，DataTables加载数据的时候报错  
					"render": function(data, type, row, meta) {

						return '<td><input class="check_item" type="checkbox" value="' + row.id + '"/></td>';
					}
					// "sClass": "text-center"
					// "bVisible" : false //此列不显示  
				}, {
					"mDataProp": "",
					"sTitle": "缩放图",
					"sDefaultContent": "",
					"sClass": "center",
					"render": function(data, type, row, meta) {
						return '<td><img src="' + row.headImg + '"/></td>';
					}
				}, {
					"mDataProp": "mainTitle",
					"sTitle": "标题<预览>",
					"sDefaultContent": "",
					"sClass": "center",
					"render": function(data, type, row, meta) {
						return '<td class="text-l"><a onclick="content_click(\'' + row.id + '\');" href="javascript:void(0)">' + row
							.mainTitle + '</a></td>';
					}
				}, {
					"mDataProp": "summary",
					"sTitle": "概要",
					"sDefaultContent": "",
					"sClass": "center"
				}, {
					"mDataProp": "type",
					"sTitle": "类型",
					"sDefaultContent": "",
					"sClass": "center",
					"render": function(data, type, row) {
						/* console.log(row)
						console.log(row.titleType) */
						if (row.titleType == "0") {
							return '<td>小知识</td>';
						} else {
							return '<td>培训</td>';
						}
					}
				}, {
					"mDataProp": "createTime",
					"sTitle": "创建日期",
					"sDefaultContent": "",
					"sClass": "center",
					"render": function(data, type, row) {
						var oldTime = (new Date(row.createTime)).getTime();
						var curTime = new Date(oldTime).format("yyyy-MM-dd hh:mm:ss");
						return '<td>' + curTime + '</td>';
					}
				}, {
					"mDataProp": "issueDate",
					"sTitle": "更新日期",
					"sDefaultContent": "",
					"sClass": "center",
					"render": function(data, type, row) {
						var oldTime2 = (new Date(row.issueDate)).getTime();
						var curTime2 = new Date(oldTime2).format("yyyy-MM-dd hh:mm:ss");
						return '<td>' + curTime2 + '</td>';
					}
				}, {
					"mDataProp": "status",
					"sTitle": "状态",
					"sDefaultContent": "",
					"sClass": "center",
					"render": function(data, type, row) {
						if (row.status == "0") {
							return '<td class="td-status"><span class="label label-success radius">草稿</span></td>';
						} else if (row.status == "1") {
							return '<td class="td-status"><span class="label label-success radius">发布中</span></td>';
						} else {
							return '<td class="td-status"><span class="label label-defaunt radius">已下架</span></td>';
						}
					}
				}, {
					"mDataProp": "",
					"sTitle": "操作",
					"sDefaultContent": "",
					"sClass": "center",
					"render": function(data, type, row) {
						//console.log(row)
						if (row.status == "0") {
							return '<td class="f-14 td-manage"><a style="text-decoration:none"  onClick="article_start(this,\'' + row.id +
								'\')" href="javascript:;" title="发布"><i class="Hui-iconfont">&#xe603;</i></a><a style="text-decoration:none" class="ml-5" onClick="article_edit(\'编辑\',\'article-edit.html\',\'' +
								row.id + '\')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a></td>';
						} else if (row.status == "1") {
							return '<td class="f-14 td-manage"><a style="text-decoration:none" onClick="article_stop(this,\'' + row.id +
								'\')" href="javascript:;" title="下架"><i class="Hui-iconfont">&#xe6de;</i></a> <a style="text-decoration:none" class="ml-5" onClick="article_edit(\'编辑\',\'article-edit.html\',\'' +
								row.id + '\')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a></td>';
						} else {
							return '<td class="f-14 td-manage"><a style="text-decoration:none" onClick="article_start(this,\'' + row.id +
								'\')" href="javascript:;" title="发布"><i class="Hui-iconfont">&#xe603;</i></a><a style="text-decoration:none" class="ml-5" onClick="article_edit(\'编辑\',\'article-edit.html\',\'' +
								row.id + '\')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a></td>';
						}

					}
				}],
				"sAjaxSource": url,
				"fnRowCallback": function(nRow, aData, iDisplayIndex) {
					/* 用来改写用户权限的 */
					if (aData.companyid == '1')
						$('td:eq(3)', nRow).html('管理员');
					if (aData.companyid == '2')
						$('td:eq(3)', nRow).html('资料下载');
					if (aData.companyid == '3')
						$('td:eq(3)', nRow).html('一般用户');
					return nRow;
				},
				"fnServerData": function(sSource, aDataSet, fnCallback) {
					$.ajax({
						"dataType": 'JSON',
						"type": "GET",
						"url": sSource,
						"data": aDataSet,
						"success": fnCallback,
					});
				}
			});
			//日期格式转换
			Date.prototype.format = function(fmt) {
				var o = {
					"M+": this.getMonth() + 1, //月份 
					"d+": this.getDate(), //日 
					"h+": this.getHours(), //小时 
					"m+": this.getMinutes(), //分 
					"s+": this.getSeconds(), //秒 
					"q+": Math.floor((this.getMonth() + 3) / 3), //季度 
					"S": this.getMilliseconds() //毫秒 
				};
				if (/(y+)/.test(fmt)) {
					fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				}
				for (var k in o) {
					if (new RegExp("(" + k + ")").test(fmt)) {
						fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
					}
				}
				return fmt;
			}

			function content_click(id) {
				var args = $.extend({
					Shade: true,
					Event: "click",
					Content: "Share",
					Title: "分享",
					contentStr: ""
				}, {
					Shade: true, //是否显示遮罩层
					Event: 'click', //触发事件
					Content: 'Share', //内容DIV ID
					Title: '手机预览', //显示标题
					contentStr: id
				});
				init(this, args);
			}

			function init(obj, args) {
				return (function() {
					fillHtml(obj, args);
					bindEvent(obj, args);
				})();
			}

			function fillHtml(obj, args) {
				return (function() {
					var layerHtml = "";
					if (args.Shade == true) {
						layerHtml += '<div class="share_layer_shade"></div>';
					}
					$.ajax({
						type: 'GET',
						url: urlPort+'/articles/getArticlesById?id=' + args.contentStr,
						data: {},
						/* beforeSend: function (request) {
							request.setRequestHeader("Authorization", "Bearer " + getToken());
						}, */
						async: false, // 同步
						dataType: 'json',
						success: function(data) {
							var kList = data.data;
							layerHtml += '<div class="share_layer_box" id="layer_' + args.Content + '">';
							layerHtml += '<h3><a  onclick="phone_close();" href="javascript:void(0)" class="close" ></a></h3>';
							layerHtml += '<div class="layer_content">';
							layerHtml += '<div id="' + args.Content + '">'; //<ul>
							layerHtml += '<div class="iphonebox">';
							layerHtml += '	<div class="webbox">';
							layerHtml += '		<div id="wrapper" class="wrapper">';
							layerHtml += '<div id="kr-article-banner" class="kr-article-banner">';
							layerHtml += '	<div id="kr-article-cover" class="kr-article-cover">';
							layerHtml += ' <img src="' + kList[0].headImg + '">';
							layerHtml += '	</div>';
							layerHtml += '	<h2 id="kr-article-title" class="kr-article-title">' + kList[0].mainTitle + '</h2>';
							layerHtml += '</div>';
							layerHtml += '<div class="kr-article-content">';
							layerHtml += '	<div class="kr-article-meta">';
							layerHtml += '		<div id="kr-article-author" class="kr-article-author">' + kList[0].author + '</div>';
							layerHtml += '		<div class="kr-article-text">发表于</div>';
							layerHtml += '		<div id="kr-article-time" class="kr-article-time">' + kList[0].issueDate + '</div>';
							layerHtml += '	</div>';
							layerHtml += '	<div id="kr-article-article" class="kr-article-article">' + kList[0].content + '</div>';
							layerHtml += '</div>';

							layerHtml += '</div>';
							layerHtml += '	</div>';
							layerHtml += '</div>';

							layerHtml += '</div></div></div></div>'; //</ul>
							$('body').prepend(layerHtml);
							//var arr = document.getElementsByClassName("wrapper");
							//alert(arr.classList.contains("container"))
							//wrapper.removeclass('container');
							//arr.classList.remove("container");

						},
						error: function(data) {
							//console.log(data.msg);
						},
					});

				})();
			}

			function bindEvent(obj, args) {
				return (function() {
					var $shareLayerBox = $('.share_layer_box');
					var $shareLayerShade = $('.share_layer_shade');
					var $ShareLi = $('#Share li');

					if (args.Event == "unload") {
						$('#layer_' + args.Content).animate({
							opacity: 'show',
							marginTop: '-30%'
						}, "slow", function() {
							$($shareLayerShade).show();
						});
					} else {
						$(obj).on(args.Event, function() {
							$('#layer_' + args.Content).animate({
								opacity: 'show',
								marginTop: '0'
							}, "slow", function() {
								$($shareLayerShade).show();
							});
						});
					}
				})();
			}

			function phone_close() {
				var $shareLayerBox = $('.share_layer_box');
				var $shareLayerShade = $('.share_layer_shade');
				$($shareLayerBox).animate({
					opacity: 'hide',
					marginTop: '-30%'
				}, "slow", function() {
					$($shareLayerBox).remove();
					$($shareLayerShade).remove();
				})
			}
			/*-添加*/
			function system_category_add(title, url, w, h) {
				layer_show(title, url, w, h);
			}
			/*编辑*/
			function article_edit(title, url, id, w, h) {
				/* var index = layer.open({
					type: 2,
					title: title,
					content: url
				});
				layer.full(index); */
				layer_show(title, url + "?id=" + id, w, h);
			}
			/*删除*/
			function datadel() {
				var ids = "";
				if ($(".check_item:checked").parents("tr").find("td:eq(4)").text() == '') {
					layer.open({
						title: '删除',
						content: '未选择任何删除项，请重新选择!'
					});
					return;
				} else {
					$.each($(".check_item:checked"), function() {
						//newsName +=$(this).parents("tr").find("td:eq(3)").text()+",";
						if (ids == "") {
							ids = $(this).parents("tr").find("td").eq(0).children('input').val();
						} else {
							ids = ids + "," + $(this).parents("tr").find("td").eq(0).children('input').val();
						}
						//ids += $(this).parents("tr").find("td:eq(3)").text() + ",";
					});
					//console.log("批量删除：" + ids)

					layer.confirm('确认要删除吗？', function(index) {
						if (ids == "") {
							layer.open({
								content: "请选择要删除项",
								title: '删除',
								yes: function(index, layero) {
									layer.close(index); //如果设定了yes回调，需进行手工关闭

								}
							});
							return;
						}

						$.ajax({
							type: 'post',
							url: urlPort+"/articles/deleteKnowledgeByIds",
							data: {
								"ids": ids
							},
							cache: false,
							/* beforeSend: function(request) {
								request.setRequestHeader("Authorization", "Bearer " + getToken());
							}, */
							dataType: 'json',
							success: function(data) {
								//console.log(data.status)
								if (data.status) {
									layer.open({
										content: "删除成功！",
										title: '删除胆/包',
										yes: function(index, layero) {
											layer.close(index); //如果设定了yes回调，需进行手工关闭
											document.location.reload();
										}
									});
									//
								} else {
									alert("删除失败，请重新删除！")
								}
							},
							error: function() {
								//alert("请求失败");
							}
						});
					});
				}
			}

			/*资讯-下架*/
			function article_stop(obj, id) {
				layer.confirm('确认要下架吗？', function(index) {
					$.ajax({
						type: 'POST',
						url: urlPort+'/articles/updateStatusOfArticleById',
						data: {
							status: "2",
							id: id
						},
						/* beforeSend: function (request) {
							request.setRequestHeader("Authorization", "Bearer " + getToken());
						}, */
						dataType: 'json',
						success: function(data) {
							if (data == "1") {
								document.location.reload();
							}
						},
						error: function(data) {
							//console.log(data.msg);
						},
					});

					layer.msg('已下架!', {
						icon: 5,
						time: 1000
					});
				});
			}

			/*资讯-发布*/
			function article_start(obj, id) {
				//console.log(id)
				layer.confirm('确认要发布吗？', function(index) {
					$.ajax({
						type: 'POST',
						url: urlPort+'/articles/updateStatusOfArticleById',
						data: {
							status: "1",
							id: id
						},
						/* beforeSend: function (request) {
							request.setRequestHeader("Authorization", "Bearer " + getToken());
						}, */
						dataType: 'json',
						success: function(data) {
							if (data == "1") {
								document.location.reload();
							}
						},
						error: function(data) {
							//console.log(data.msg);
						},
					});
					layer.msg('已发布!', {
						icon: 6,
						time: 1000
					});
				});
			}
		</script>
	</body>
</html>
